package com.yxq.mdt.app.modules.market.ui;

import android.graphics.Paint;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.market.bean.MallResponseBean;

import java.util.List;

/**
 * @author L
 * @time 2019-10-21
 * @describe 商城秒杀商品数据适配器
 */
public class MainMallPanicBuyListAdapter extends BaseQuickAdapter<MallResponseBean.MiaoshaBean.GoodsListBean, BaseViewHolder> {


    public MainMallPanicBuyListAdapter(int layoutResId, @Nullable List<MallResponseBean.MiaoshaBean.GoodsListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MallResponseBean.MiaoshaBean.GoodsListBean item) {

        ImageView icon = helper.getView(R.id.main_item_iv_grid_icon);
        GlideHelper.setLoadRoundImage(mContext, item.getPic(), R.color.gray, icon);
        helper.setText(R.id.main_item_tv_grid_title, item.getName());
        TextView priceView = helper.getView(R.id.main_item_tv_grid_price);
        priceView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        priceView.setText(String.format("￥%.2f", item.getPrice()));
        helper.setText(R.id.main_item_tv_grid_sell_price, (String.format("￥%.2f", item.getMiaosha_price())));
    }
}
